package com.tlx.core.util;

import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;

@SuppressWarnings("rawtypes")
public class PrintUtils {
    public static void printMap(Map map) {
        if (map == null) {
            System.out.println(map);
        }

        System.out.println(JSONObject.toJSONString(map, SerializerFeature.PrettyFormat,
                SerializerFeature.WriteMapNullValue, SerializerFeature.WriteDateUseDateFormat));
    }

    public static void print(Object obj) {
        if (obj instanceof int[]) {
            int[] o = (int[]) obj;
            for (int i : o) {
                System.out.print(i + " ， ");
            }
        } else if (obj.getClass().isArray()) {
            // Arrays.asList(obj).stream().forEach(x -> System.out.println(x));
            System.out.println(obj);
        } else {
            System.out.println(obj);
        }
    }

    public static void printErr(Exception e, String info) {
        System.out.println(info);
        if (e != null) {
            e.printStackTrace();
        }
    }

    public static void printErr(String info) {
        System.out.println(info);
    }
}
